#ifndef __KEYFRAMEDATABASE_H__
#define __KEYFRAMEDATABASE_H__

#include <vector>
#include <list>
#include <set>

#include <DBoW3/DBoW3.h>
#include "../include/Frame.hpp"
#include "../include/Map.hpp"

#include <mutex>
using namespace std;
namespace ORBSLAM
{
    class Frame;
    class KeyFrame;
    class Map;

    class KeyFrameDatabase
    {
    private:
        /* data */
    public:
        KeyFrameDatabase(/* args */);
        ~KeyFrameDatabase();
        KeyFrameDatabase(const DBoW3::Vocabulary &vocabulary);
        void Add(KeyFrame *p_keyframe);
        void Erase(KeyFrame *p_keyframe);
        vector<KeyFrame*> Detect_relocalization_candidates(Frame* p_frame,Map* p_map);
        void Detect_nbest_candidates(KeyFrame* p_keyframe,vector<KeyFrame*> &vp_loop_cand,vector<KeyFrame*> &vp_merge_cand,int candidates_num);

    protected:
        const DBoW3::Vocabulary *mp_vocabulary;
        vector<list<KeyFrame *>> mvlp_invert_index;
        mutex mmutex_keyframe_db;
    };

}
#endif // __KEYFRAMEDATABASE_H__